package com.example.pingxue.entity;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import jakarta.persistence.*;
import lombok.Getter;
import lombok.Setter;

import java.util.HashSet;
import java.util.Set;

@Entity
@Getter
@Setter
@DiscriminatorValue("0")
public class Student extends User{
    @Column
    private String studentName;
    @Column
    private String major;
    @Column
    private String grade;
    @Column
    private String school;

    @OneToMany(mappedBy = "student", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY)
    @JsonIgnoreProperties(value = {"student", "handler", "hibernateLazyInitializer"})
    private Set<Selection> selections = new HashSet<>();

    public Student() {}
    public Student(String studentName, String major, String grade, String school) {
        this.studentName = studentName;
        this.major = major;
        this.grade = grade;
        this.school = school;
    }

//    public void selectClass(Class clazz) {
//        Selection selection = new Selection(this, clazz);
//        this.selections.add(selection);
//        clazz.getSelections().add(selection);
//    }
//
//    public void dropClass(Class clazz) {
//        this.selections.removeIf(selection -> selection.getClass().equals(clazz));
//        clazz.getSelections().removeIf(selection -> selection.getClass().equals(clazz));
//    }
}
